package com.Abstract;

abstract class Employees {
    private int temp;

    public Employees(int temp) {
        this.temp = temp;
    }

    public int getTemp() {
        return temp;
    }

    public abstract void work();

    public void dosomething() {
        System.out.println("抽象类中的实例方法已执行");
    }
}

class Manager extends Employees {

    public Manager(int temp) {
        super(temp);
    }

    @Override
    public void work() {
        System.out.println("班主任要管理学生~~");
    }
}

class Teacher extends Employees {
    public Teacher(int temp) {
        super(temp);
    }

    @Override
    public void work() {
        System.out.println("老师要教育学生~~");

    }
}

//测试类：
public class AbstractDemo {
    public static void main(String[] args) {
        Manager manager = new Manager(10);
        Teacher teacher = new Teacher(20);

        manager.work();
        teacher.work();

        manager.dosomething();
        System.out.println(manager.getTemp());
        System.out.println(teacher.getTemp());

        /**
         *         //测试抽象类能否创建对象
         *         Employees employees;//声明抽象类对象
         *         employees = manager;//manager是employee的具体化类，可以向上转型复制给父类的引用变量
         *         employees.work();
         */
    }

}

/**
 * 要点总结：
 * 1.抽象类中可以有数据成员，也可以有实例方法，供实现类使用
 * 2.
 */
